home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
GameKit
/
Examples
/
PacMan
/
Player.h
< prev
next >
Wrap
Text File
|
1995-06-12
|
2KB
|
49 lines
// Handles moving and rendering the Pac, whether under player or demo control.
#import <gamekit/gamekit.h>
// legal directions to use as arguments to -newDirection: method
// also, as bitmasks for various arrays.
#define PAC_UP 0x08
#define PAC_DOWN 0x04
#define PAC_LEFT 0x02
#define PAC_RIGHT 0x01
#define PAC_STOP 0 // default; if not one of the above, we assume stopped
#define PAC_WIDTH 16 // width of a pac image in pixels (square)
// legal states the Pac can be in
#define PAC_DEAD 0
#define PAC_ALIVE 1
#define PAC_DYING -11 // ten steps in death animation, then fully dead
@interface Player:GameActor
{
id maze; // Maze
id pacsLeft; // PlayerUpView
id pacs[3]; // pac images
int curDir; // which way the player wants to go
int nextDir; // which way the player wants to go next
int pacX, pacY; // where we're at
int state; // alive, dead, etc.
int cycle; // frame counter for animation
BOOL playerStopped; // true if player hit space bar to stop
}
- init; // initialize the player
- (BOOL)newPlayer; // get and set up a new Pac. Returns NO if can't
- resetPlayer; // reset all player info
- (BOOL)pacAlive; // returns YES if Pac is alive
- pacDie; // the pac will melt
- move:sender; // Move the PacMan one animation frame
- demoMove:sender; // Move the PacMan one animation frame (demo cntl)
- newDirection:(int)newDir; // send Pac in new direction.
- renderAt:(int)posx :(int)posy move:(BOOL)moveOk; // draw pac
// you should lock focus on view that gets the Pac first.
@end